package main

import "fmt"

type speaker interface {
	speak() string
}

type dog struct {
	name string
}

type cat struct {
	name string
}

func (d dog) speak() string {
	return fmt.Sprint(d.name, "--->", "汪汪 !")
}

func (c cat) speak() string {
	return fmt.Sprint(c.name, "-->", "喵喵！")
}

func mainInterface() {
	dog1 := dog{name: "旺财"}
	cat1 := cat{name: "cat"}
	doSpeak(cat1)
	doSpeak(dog1)
}

func doSpeak(speaker speaker) {
	fmt.Println(speaker.speak())
}
